/**
 * 功能描述 导航
 */

define(function (require, exports, module) {
	var Component = require("subnav");
	var enmu=require("enums");
	var aw = require("ajaxwrapper");
	var user = require("store").get("user");
	var fetchProperties = require("../constant/fetchProperties");
	
    var instance = {
        initComponent: function (params, widget) {
            var component = new Component({
            	parentNode:".J-subnav",
				model : {
					title:"水电费抄表",
					items : [{
						id : "servicePoint",
						text : "服务点",
						tip : "服务点",
//						url:"api/servicepoint/operableservicepoints",
//						lazy:true,
						items:user.privateServicePoints,
						type : "buttongroup",
						keyField : "pkServicePoint",
						valueField : "name",
						all: {
							show: true,
							position: "bottom"
						},
						handler:function(key,element){	
							widget.get("grid").refresh();
						}
					},{
						id : "checkInStatus",
						type:"buttongroup",
						tip:"状态",
					    items:[{
							key:"NoCheckIn",
							value:"待入住",
						},{
							key:"CheckIn",
							value:"待退住"
						},{
							key:"Accomplish",
							value:"完成"
						},{
							key:"",
							value:"全部"
						}],
						handler : function(time){
							 widget.get("grid").refresh();
						}
					},{
        				id: "return",
        				type: "button",
						text: "返回",
						show: false,
						handler: function(){
							widget.detail = false;
							widget.show([".J-grid"]).hide([".J-watergrid",".J-waterform"]);
							widget.get("subnav").hide(["return"]).show(["servicePoint","checkInStatus", "checkInDate"]);
							widget.get("grid").refresh({
								"checkInStatus" : component.getValue("checkInStatus"),
								"pkServicePoint" : component.getValue("servicePoint"),
								"startDate" : component.getValue("checkInDate").start,
								"endDate" : component.getValue("checkInDate").end,
								fetchProperties:fetchProperties.gridFetchProperties
						});
						}
        				
        			},{
						id : "checkInDate",
						tip:"入住日期",
						type:"daterange",
						ranges : {
							"最近30天": [moment().add("days",-30).startOf("days"), moment().add("days",30).endOf("days")],
						},
						defaultRange : "最近30天",
						handler : function(time){
							 widget.get("grid").refresh();
						}
					}]
				}
            });
            widget.set("subnav", component);
        }
    };
    module.exports = instance;
});
